package WaiBao;

import java.util.Arrays;

public class ZhangMengYao {
    public static void main(String[] args) {
        String[] name = {"李开瑛(班长)", "刘在嗨(副班长)", "小李(学习委员)", "康永庆(体育委员)", "刘来有(纪律委员)", "石双厚", "四天才", "石算柱", "石丽君", "周依依", "邱整数", "文装祥",
                "宁雨欣", "陆从风", "李菜早", "贺易", "戚院", "邱樊荣", "刘先发", "蔡蔡", "莫李恩", "郝秒", "梁成金", "何刚明", "莫两紧", "严席华", "张顺联", "唐映政",
                "卢君君", "张梦瑶(学生)"};//考生本人:张梦瑶(学生)
        int[] age = {21, 18, 19, 21, 20, 18, 21, 18, 19, 19, 18, 19, 18, 20, 21, 19, 18, 19, 18, 20, 19, 19, 20, 20, 20, 18, 20, 20, 19, 20};//考生年龄：20

        double[] bainian1 = {87, 79, 80, 85, 74, 68, 71, 80, 68, 80, 90, 77, 80, 72, 64, 68, 69, 99, 96, 80, 92, 91, 90, 85, 75, 74, 74, 84, 87, 96};
        double[] bainian2 = {64, 84, 67, 84, 79, 86, 79, 84, 69, 74, 84, 67, 84, 75, 95, 64, 86, 79, 66, 78, 82, 71, 85, 87, 75, 89, 74, 70, 85, 97};
        double[] bainian3 = {89, 85, 79, 74, 85, 75, 63, 89, 80, 69, 73, 87, 85, 85, 65, 98, 89, 79, 96, 63, 92, 81, 95, 85, 76, 88, 73, 78, 74, 95};

        double ben1;//代表每个学生的总分
        double ben2;//代表每个学生的平均分
//        for (int i = 0; i < 30; i++) {
//            ben1 =bainian1[i] + bainian2[i] + bainian3[i];
//            ben2 = (ben1 * 1.0) / 3;
//            System.out.println(name[i] + "的总分为:" +ben1);
//            System.out.println(name[i] + "的平均分为:" + ben2);
//        }


        double wang1 = 0,wang2 = 0;
        double[] wuli = new double[30];
        for (int i = 0; i < 30; i++) {
            wang1 = bainian1[i] + bainian2[i] + bainian3[i];
            wang2 = (wang1 * 1.0) / 3;
            wuli[i] =wang2;
        }

        for (int i = 0; i <wuli.length - 1; i++) {
            for (int j = 0; j <wuli.length - i - 1; j++) {
                if (wuli[j] <wuli[j + 1]) {
                    double tep =wuli[j];
                    wuli[j] = wuli[j + 1];
                    wuli[j + 1] = tep;
                }
            }
        }
        System.out.println("前十名同学的成绩为:");
        for (int i = 0; i < 10; i++) {
            System.out.println(wuli[i]);
        }


        double huanhuan1 = 0,huanhuan2 = 0, huanhuan3 = 0;//计算每门课的平均分
        double xiaoyuun1 = 0,xiaoyuun2 = 0,xiaoyuun3 = 0;//计算每门课标准差
        double tuandui1 = 0, tuandui2 = 0, tuandui3 = 0;//计算每门课中位数
        double sap = 0;
        for (int i = 0; i <bainian1.length; i++) {
            sap+= bainian1[i];
        }
        huanhuan1 = (sap*1.0)/30;
        System.out.println("分析化学的班级平均分为:"+ huanhuan1);
        double Sum = 0;
        for (int i = 0; i < bainian2.length; i++) {
            Sum+=bainian2[i];
        }
        huanhuan2 = (Sum*1.0)/30;
        System.out.println("线性代数的班级平均分为:"+huanhuan2);
        double sum = 0;
        for (int i = 0; i <bainian3.length; i++) {
            sum+=bainian3[i];
        }
        huanhuan3 = (sum*1.0)/30;
        System.out.println("有机化学的班级平均分为:"+huanhuan3);




        double c1 = 0,c2 = 0,c3 = 0;
        for (int i = 0; i <bainian1.length; i++) {
            c1+= (bainian1[i] - huanhuan1)*(bainian1[i] -huanhuan1);
        }
        xiaoyuun1 = Math.sqrt(c1*1.0/30);
        System.out.println("分析化学的班级标准差为:"+xiaoyuun1);

        for (int i = 0; i <bainian2.length; i++) {
            c2+= (bainian2[i] - huanhuan2)*(bainian2[i] -huanhuan2);
        }
        xiaoyuun2 = Math.sqrt(c2*1.0/30);
        System.out.println("线性代数的班级标准差为:"+xiaoyuun2);

        for (int i = 0; i <bainian3.length; i++) {
            c3+= (bainian3[i] - huanhuan3)*(bainian3[i] - huanhuan3);
        }
        xiaoyuun3 = Math.sqrt(c3*1.0/30);
        System.out.println("有机化学的班级标准差为:"+ xiaoyuun3);
////////////
//////////
//////////
//        Arrays.sort(bainian1);
//        Arrays.sort(bainian2);
//        Arrays.sort(bainian3);
//        tuandui1 =( bainian1[14]+bainian1[15])*1.0/2;
//        tuandui2 =(bainian2[14]+ bainian2[15])*1.0/2;
//        tuandui3 =( bainian3[14]+bainian3[15])*1.0/2;
//        System.out.println("分析化学的中位数为:"+  tuandui1);
//        System.out.println("线性代数的中位数为:"+ tuandui2);
//        System.out.println("有机化学的中位数为:"+ tuandui3);

    }
}
